package com.huluobo.a2302mdmdemo.demo

import com.huluobo.lib_base.BaseViewModel
import com.huluobo.lib_base.StateType
import com.huluobo.lib_base.UIIntent
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

/**
 *  Created by LC on 2025/7/25.
 */
@HiltViewModel
class MineViewModel @Inject constructor(private val mineRepo: MineRepo) : BaseViewModel<MineIntent>() {
    override fun handleIntent(it: UIIntent) {
        when (it) {
            is MineIntent.Register -> {
                roomRequest(mineRepo.register(it.user))
            }

            is MineIntent.Login -> {
                roomRequest(mineRepo.login(it.username, it.password, it.role), StateType.LOGIN)
            }

            is MineIntent.QueryAll -> {
                roomRequest(mineRepo.queryAll(), StateType.QUERY_ALL)
            }

            is MineIntent.Delete -> {
                roomRequest(mineRepo.deleteUser(it.user), StateType.DELETE)
            }
        }
    }
}